#!/usr/bin/env python

import pymongo
import datetime

import itertools

def type():
    return next(t)

def main():
    
    conn = pymongo.MongoClient(host='192.168.0.20', port=27017)
    
    db = conn['rbs']
    
    queue = db['queue']
    
    types = ['el7', 'el6', 'el5']
    
    packages = ['ledaps', 'cfmask', 'python', 'dem']
    
    boolean = ['True', 'False', 'False']
    
    arch = ['x86_64', 'i386', 'armv5']
    
    t = itertools.cycle(types)
    
    p = itertools.cycle(packages)
    
    b = itertools.cycle(boolean)
    
    a = itertools.cycle(arch)
    
    queue.ensure_index([('package', pymongo.ASCENDING),('ostype', pymongo.ASCENDING)], unique=True)
    
    for n in range(1,5, 1):
        # Old way---07/12/2013
        #
        #q = {}
        #q['submittime'] = datetime.datetime.now() + datetime.timedelta(hours=n)
        #q['ostype'] = next(t)
        #q['package'] = next(p)
        #q'deploy'] = next(b)
        
        # New document design
        queue.insert({
            'package': next(p),
            'ostype': next(t),
            'arch': next(a),
            'build': {
                'submittime': datetime.datetime.now() + datetime.timedelta(hours=n)
            },
            'repo': {
                'deploy': next(b)
            }
        })

if __name__ == '__main__':
    main()



